class TreeOp {
  constructor() {
    this.items = [];
  }
  addNewGroup(treeData, classify) {
    if (this.items.indexOf(classify) < 0) {
      treeData[0].children.push({
        title: classify,
        key: classify,
        slots: {
          icon: "second",
        },
      });
      this.items.push(classify);
    }
  }
  getClassifyByIndex(treeData, currentInputClassifyIndex) {
    return treeData[0].children[currentInputClassifyIndex].title;
  }
  addToTree(treeData, rows) {
    this.items.splice(0, this.items.length);
    treeData[0].children.splice(0, treeData[0].children.length);
    for (let i = 0; i < rows.length; i++) {
      let classify = rows[i].json.classify;
      if (this.items.indexOf(classify) < 0) {
        treeData[0].children.push({
          title: classify,
          key: classify,
          slots: {
            icon: "second",
          },
        });
        this.items.push(classify);
      }
    }
  }
  // addToTree(treeData, arr) {
  //   for (let i = 0; i < arr.length; i++) {
  //     let classify = arr[i].json.classify;
  //     treeData[0].children.push({
  //       title: classify,
  //       key: classify,
  //       slots: {
  //         icon: "second",
  //       },
  //     });
  //   }
  // }
}
export default new TreeOp();
